

<script type="text/javascript">

function goToMenu(menuName){
<%= update_page do |page| 
  page.select("#options_bar .menu").each {|menu|  menu.hide }
  page << "$(menuName).show();return false;"
end %>
}
Position.includeScrollOffsets = true;

</script>


<div id="compages">
  <% apply_behaviour "#restore_bar", make_draggable %>
  <div id="restore_bar">
    <div id="restore_bar_ie">
      <span class="drag_handle">Drag me...</span><br/>
      <input type="hidden" id="selected_element" name="selected_element" value=""/>
      <%= link_to_remote "Remove!", {:url=>{:controller=>"contents", :action=>"remove_page_element", :id=>@page.id }, :submit=>"restore_bar"}, {:id=>"remove_element", :style=>"position:relative;display:none;"} %> or
      <%= link_to_remote "Edit...", {:url=>{:controller=>"contents", :action=>"edit_page_element", :id=>@page.id }, :submit=>"restore_bar"}, {:id=>"edit_element", :style=>"color:blue;position:relative;display:none;"} %>
      <br/><%= link_to_function "Show Options", update_page{|p| p['compages_bar_wrapper'].visual_effect :appear, :duration=>0.2; p['restore_bar'].hide;p['hide_bar'].visual_effect :pulsate, :duration=>2 }, :style=>"position:relative;"%>
    </div>
  </div>
  
  <div id="compages_bar_wrapper" style="display: none;">
    <div id="options_bar">
      <div id="hide_bar"><%= link_to_function "hide this bar", update_page {|p| p['compages_bar_wrapper'].visual_effect :fade, :duration=>0.2; p['restore_bar'].show } %></div>
      
  		<ul id="main_menu" class="menu">
  		  <span class="back"><%= link_to "&laquo; BACK", :action => "list" %></span>
  			<li><%= link_to_function "Add some content", "goToMenu('add_content_menu');" %></li>
  			<li id="highlight_areas"><%= link_to_function "highlight areas", update_page{|p|
              p.select('.compages_area').each{|area| area.set_style :outline=>"3px solid #ffffaa;" }
              p["highlight_areas"].hide;p["restore_highlighted_areas"].show } %>
        </li>
  			<li id="restore_highlighted_areas" style="display:none;background:#ffffaa;">
          <%= link_to_function "highlight areas", update_page{|p|
              p.select('.compages_area').each{|area| area.set_style :outline=>"none;" }
              p["highlight_areas"].show;p["restore_highlighted_areas"].hide } %>
        </li>
  			
  			<li id="change_theme"><%= link_to_remote "Change the page Theme", :url=>{:action=>"select_theme", :id=>@page.id } %></li>
  		</ul>
  		
  		<ul id="add_content_menu" class="menu" style="display:none" >
  		  <li class="back"><%= link_to_function "&laquo; BACK", "goToMenu('main_menu');" %></li>
  			<li><%= link_to_remote "Write now!", :url=>{:controller=>"contents", :action=>"write_now", :id=>@page.id } %></li>
  			<li><%= link_to_remote "Pick from library...", :url=>{:controller=>"contents", :action=>"show_library", :id=>@page.id } %></li>
  		</ul>
  		
  		<ul id="write_content_menu" class="menu" style="display:none" >
  		  <li class="back"><%= link_to_function "&laquo; Cancel", update_page{|p| p<< "goToMenu('add_content_menu');"; p.replace_html "widgets", ""} %></li>
  		</ul>
  		
  		<ul id="edit_content_menu" class="menu" style="display:none" >
  		  <li class="back"><%= link_to_function "&laquo; Cancel", update_page{|p| p<< "goToMenu('main_menu');"; p.replace_html "widgets", ""} %></li>
  		</ul>
  		
  	</div>
  	<div id="widgets"></div>
    <%= if_ie_tag %{<div id="ie_shadow">&nbsp;</div>} %>
  </div>
  
</div>